﻿@inherits OperationDialogBase<OperationDialogInput<Guid>, OperationDialogOutput<Guid>, EmailLocalResource>

<Form Loading="@_isLoading"
      Model="@_sendEmailInput"
      LabelCol="new ColLayoutParam { Span = 8 }"
      WrapperCol="new ColLayoutParam { Span = 16 }"
      OnFinish="OnFormFinish"
      Context="model">
    <FormItem Label="@Localizer[nameof(EmailLocalResource.EmailServerConfig)]">
        <Input Disabled="true" @bind-Value="@model.EmailServerConfigId" />
    </FormItem>
    <FormItem>
        <Input @bind-Value="@model.ToEmail" />
    </FormItem>
    <FormItem Label="@Localizer[nameof(SharedLocalResource.Data)]">
        <TextArea AutoSize="true" MinRows="2" MaxRows="6" @bind-Value="@_emailData"></TextArea>
    </FormItem>
    <FormItem Label="@Localizer[nameof(EmailLocalResource.EmailTemplate)]">
        <Select DataSource="@emailTemplates"
                @bind-Value="@model.TemplateId"
                ValueName="@nameof(EmailTemplateDto.Id)"
                LabelName="@nameof(EmailTemplateDto.Name)"
                OnSelectedItemChanged="OnEmailTemplateChanged"
                TItem="EmailTemplateDto"
                TItemValue="Guid"
                >
        </Select>
    </FormItem>

    <FormItem WrapperColOffset="8" WrapperColSpan="16">
        <Space>
            <SpaceItem>
                <Button Type="@ButtonType.Primary" HtmlType="submit">
                    @Localizer[nameof(SharedLocalResource.Send)]
                </Button>
            </SpaceItem>
            <SpaceItem>
                <Button OnClick="_=>OnFormCancel()">
                    @Localizer[nameof(SharedLocalResource.Cancel)]
                </Button>
            </SpaceItem>
        </Space>
    </FormItem>
</Form>